
<table height="320px" width="603px">
				<tr><td id="info" valign="top">
					<table cellpadding="0" cellspacing="0" >
						<tr><td width="395px" valign="top">
						<?php include 'navbar.php'; ?>
						</td>
						<td>&nbsp;</td>
						<td valign="top">
							<table cellpadding="0" cellspacing="0" border="0" align="right" width="185px"><tr><td>
							<?php 
							
							$username = $_SESSION['username'];          					$query = "select * from user where username='$username'";         					$result = mysql_query($query);
							$user = mysql_fetch_array($result);
							$temp = $user['nick'];
							if (empty($temp)) { include 'guestgreet.php'; } else{ include 'usergreet.php'; } ?>
							</td></tr><tr><td id="login"><div align="right"><span style="font-size:12px"><? echo $user['nick']; ?></span> ( <strong><?php if (is_authed()) { echo '<a href="index.php?act=logout">Logout</a>';} else {echo '<a href="register.php">Register</a> | <a href="index.php">Log In</a> ';} ?> </strong> )</div></td></tr></table>
					

						</td></tr>
					</table>

					<table cellpadding="0" cellspacing="0"><tr><td width="385px" valign="top">
					<div align="left"><h3>Search for a Mii Name</h3>
					<span style="font-size:10px">Seek vengence, preserve justice..</span> <br /><br />
					
						<?php					if (!isset($_POST['submit']) && empty($var))					{     					// Show the form     					include 'search_form.inc.php';					}					else					{
					
						if (empty($var)) {$var = $_POST['thesearch'];}
					    $trimmed = trim($var);

						// rows to return

						$limit = 10; 
						echo '<span style="font-size:10px">';

						// check for an empty string and display a message.
						if ($trimmed == "")
						  {
						  $search_error = 'Fail. Please enter a search...';
						  $error = '1';          				  include 'search_form.inc.php';
						  }

						// check for a search parameter
						if (!isset($var))
						  {
						  $search_error = 'Nothing to search for..';
						  $error = '1';          				  include 'search_form.inc.php';
  						  }


						// Build SQL Query  
						if (empty($search_error)) {
						$query = "select * from user where nick like \"%$trimmed%\"  
					    order by nick"; 
 						$numresults=mysql_query($query);
					    $numrows=mysql_num_rows($numresults);

						if ($numrows == 0)
						  {
						  $search_error = 'Your search for &quot;' . $trimmed . '&quot; returned nothing...';
						  $error = '1';          				  include 'search_form.inc.php';						  
						  }
						$result = mysql_query($query) or die("Couldn't execute query");
						$row= mysql_fetch_array($result);
						$userno = $row['userid'];
					    

						if ($numrows == 1)
						  {
						  echo '<script>							<!-- 								 window.location= "http://www.mariokartchallenger.com/index.php?showuser=', $userno, '"							//-->							</script>';
						  exit;

						  }
						
						// next determine if s has been passed to script, if not use 0
						  if (empty($s)) {
						  $s=0;
						  }

						// get results
						  $query .= " limit $s,$limit";
						  $result = mysql_query($query) or die("Couldn't execute query");

						// begin to show results set
						$count = 1 + $s ;

						// now you can display the results returned
						  while ($row= mysql_fetch_array($result)) {
						  $title = $row["nick"]; $link = $row["userid"];

						  echo "<span style='font-size:12px'>$count)&nbsp;<a href='http://www.mariokartchallenger.com/index.php?showuser=$link'>$title</a></span><br />" ;
						  $count++ ;
						  }

						$currPage = (($s/$limit) + 1);

						//break before paging
						  echo "<br />";

						  // next we need to do the links to other results
						  if ($s>=1) { // bypass PREV link if s is 0
						  $prevs=($s-$limit);
						  print "&nbsp;<strong><a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt; 
  Prev 10</a>&nbsp&nbsp;</strong>";
  						}

						// calculate number of pages needing links
						  $pages=intval($numrows/$limit);

						// $pages now contains int of pages needed unless there is a remainder from division

						  if ($numrows%$limit) {
						  // has remainder so add one page
						  $pages++;
						  }

						// check to see if last page
						  if (!((($s+$limit)/$limit)==$pages) && $pages!=1 && empty($search_error)) {

						  // not last page so give NEXT link
						  $news=$s+$limit;

						  if (is_authed()) { echo "&nbsp; <strong><a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 &gt;&gt;</a></strong>";} else { echo '<strong><a href="register.php">Register for more results..</strong></a>';}
  }

						$a = $s + ($limit) ;
						  if ($a > $numrows) { $a = $numrows ; }
						  $b = $s + 1 ;
						  //echo "<p>Showing results $b to $a of $numrows</p>";
   					}						echo '</span>';
}					?>


</div>
					</td><td valign="top">
                         <div align="right">
							<?php
                            if (is_authed()) { include 'sidebar.php';} elseif (!is_authed()) { echo '' ;} ?>						</div>
					</td></tr></table>
				
					</td></tr>
			</table>
			</td>
		</tr>
	</table>


<?php include 'footer.php' ?>
